%
% cc_nm_interp1.m
%
%  Form the 1D linear interpolation matrix for a cell centered grid.
%
% input -- Nf = number of cell centers on the fine grid
% output -- 
%
function Ip = cc_nm_interp1(Nf);
  
if Nf<=2
    Ip = cc_nm_interp1_const(Nf);
    return;
end

  % number of centers on the coarse grid
  %
  Nc = Nf/2;
  
  % allocate space for the matrix
  %
  Ip = spalloc(Nf,Nc,3*Nc);
  
  % first column
  %
  Ip(1:3,1) = [0.75; 0.75; 0.25];
  % periodic BC, change needed for other BCs.
  Ip(Nf,1) = 0.25;
  
  % last column
  %
  Ip((Nf-2):Nf,Nc) = [0.25; 0.75; 0.75];
  % periodic BC, change needed for other BCs.
  Ip(1,Nc) = 0.25;
    
  % loop over columns
  %
  for j=2:Nc-1
      ifine = 2*j;
      Irange = [ifine-2:ifine+1]; 
      Ip(Irange,j) = [0.25; 0.75; 0.75; 0.25];
  end
